package com.autohammal.factory;

import com.autohammal.work.Work;

public class WorkFactory {

	private WorkFactory() {
	}

	public static Work getWork() {
		return WorkContainer.getWork0();
	}

	public static Work getAidWork() {
		return WorkContainer.getWork1();
	}

	private static class WorkContainer {
		private static Work _0_instance = new Work();
		private static Work _1_instance = new Work(Work.DEFAULT_CAPACITY);

		private static Work getWork0() {
			Work work = _0_instance == null ? new Work() : _0_instance;
			if (!work.isRunState())
				work.start();
			return work;
		}

		private static Work getWork1() {
			Work work = _1_instance == null ? new Work(Work.DEFAULT_CAPACITY)
					: _1_instance;
			if (!work.isRunState())
				work.start();
			return work;
		}
	}

}
